package com.yanqu.controller;

import com.yanqu.data.entity.LogGoodsEntity;
import com.yanqu.manager.UserGetGoodsMonitorMgr;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/")
public class GoodsGetLogController {

    private static final Logger logger = LogManager.getLogger(GoodsGetLogController.class.getName());

    //道具获得收集
    @PostMapping("/goodsGet")
    public Object goodsGet(HttpServletRequest request, @RequestBody List<LogGoodsEntity> goodsEntityList) {
        long start = System.currentTimeMillis();
        for (LogGoodsEntity entity : goodsEntityList) {
            UserGetGoodsMonitorMgr.recordLogGoodsEntity(entity);
        }
        long cost = System.currentTimeMillis() - start;
        if(cost > 50) {
            logger.info("goodsGet collect log  cost {}",  cost);
        }
        return "{\"ret\": 0}";
    }

}
